package com.tdkj.action.backstage.website;

import java.util.HashSet;
import java.util.Set;

import javax.annotation.Resource;

import com.tdkj.action.BaseAction;
import com.tdkj.model.website.BeanWebsiteOnline;
import com.tdkj.model.website.BeanWebsiteParam;
import com.tdkj.service.website.IBeanWebsiteParamService;
public class WebsiteParamAction  extends BaseAction{
	private IBeanWebsiteParamService websiteParamService;
	private long id;
	private String paramname;
	private String keywords;
	private Set<BeanWebsiteOnline> websiteOnlines = new HashSet<BeanWebsiteOnline>(0);
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getParamname() {
		return paramname;
	}
	public void setParamname(String paramname) {
		this.paramname = paramname;
	}
	public String getKeywords() {
		return keywords;
	}
	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}
	public Set<BeanWebsiteOnline> getWebsiteOnlines() {
		return websiteOnlines;
	}
	public void setWebsiteOnlines(Set<BeanWebsiteOnline> websiteOnlines) {
		this.websiteOnlines = websiteOnlines;
	}
	public IBeanWebsiteParamService getWebsiteParamService() {
		return websiteParamService;
	}
	@Resource
	public void setWebsiteParamService(IBeanWebsiteParamService websiteParamService) {
		this.websiteParamService = websiteParamService;
	}
	
	//获取网站参数编辑界面
	public String getEditPage(){
		BeanWebsiteParam bean=new BeanWebsiteParam();
		bean=websiteParamService.findById(1L, BeanWebsiteParam.class);
		if(bean!=null){
			this.setId(bean.getId());
			this.setKeywords(bean.getKeywords());
			this.setParamname(bean.getParamname());
		}
		return "editPage";
	}
	
	//保存网站参数设置
	public String addWebsiteParam(){
		BeanWebsiteParam bean=new BeanWebsiteParam();
		bean.setKeywords(this.getKeywords());
		bean.setParamname(this.getParamname());
		if(this.getId()==1){
			bean.setId(this.getId());
			websiteParamService.merge(bean);
		}else{
			websiteParamService.save(bean);
		}
		return getEditPage();
	}

}
